package org.qnit.util

import org.apache.spark.sql.{DataFrame, SaveMode}

object MysqlUtil {

  val jdbcUrl = "jdbc:mysql://node1:3306/qnit?useUnicode=true&characterEncoding=UTF-8"
  val username = "root"
  val password = "qnit123"

  def save(df: DataFrame, tableName: String) = {
    df.write.mode(SaveMode.Overwrite).format("jdbc")
      .option("url", jdbcUrl)
      .option("driver", "com.mysql.jdbc.Driver")
      .option("dbtable", tableName)
      .option("user", username)
      .option("password", password)
      .save()
  }

}
